﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;
using WeiXinSDK.DataModel.Enum;

namespace WeiXinSDK.DataModel
{
    public class Button
    {
        private ButtonType _ButtonType = ButtonType.View;

        /// <summary>
        /// 菜单的响应动作类型，目前有click、view两种类型， 无需提交到微信
        /// </summary>
        [ScriptIgnore]
        public ButtonType ButtonType
        {
            get { return _ButtonType; }
            set { 
                _ButtonType = value;
                type = this.ButtonType.ToString().ToLower();
            }            
        }

        private string _type;
        /// <summary>
        /// 菜单的响应动作类型,，value由ButtonType得到，只为序列化提交到微信
        /// </summary>
        public string type
        {
            get { return _type; }
            set { _type = value; }      
        }

        private string _name = string.Empty;

        /// <summary>
        /// 菜单标题，不超过16个字节，子菜单不超过40个字节
        /// </summary>
        public string name
        {
            get { return _name; }
            set { _name = value; }
        }

        private string _key = null;

        /// <summary>
        /// click类型必须,菜单KEY值，用于消息接口推送，不超过128字节
        /// </summary>
        public string key
        {
            get { return _key; }
            set { _key = value; }
        }

        private string _url = null;

        /// <summary>
        /// view类型必须,网页链接，用户点击菜单可打开链接，不超过256字节
        /// </summary>
        public string url
        {
            get { return _url; }
            set { _url = value; }
        }

        /// <summary>
        /// 二级菜单数组，个数应为1~5个
        /// </summary>
        public List<Button> sub_button { get; set; }
    }
}
